package pos.tests;

import java.util.Date;
import java.util.LinkedList;
import java.util.List;


import pos.domain.Address;
import pos.domain.CreditCard;
import pos.domain.Detail;
import pos.domain.IPOSProcessor;
import pos.domain.Order;
import pos.domain.POSProcessor;
import pos.domain.Product;

public class TestCreateOrder {

	/**
	 * @param args
	 */
	public static void main(String[] args) {


		//create the address
		Address a = new Address();
		
		a.setCity("sevilla");
		a.setEmail("benavides@us.es");
		a.setFax("95455656968");
		a.setName("David");
		a.setPhone("95455656968");
		a.setStreet("reina mercedes");
		a.setZipcode(41013);
		
		
		//create the credit card
		CreditCard cc = new CreditCard();
		
		cc.setHolder("David Benavides");
		cc.setNumber("123456789123");
		cc.setMonth(12);
		cc.setYear(2014);
		
		
		//create the products to be selected
		Product p1 = new Product();
		Product p2 = new Product();
		
		p1.setProductID("1");p2.setProductID("2");
		
		//add the details of the order
		Detail d1 = new Detail();
		Detail d2 = new Detail();
		
		
		d1.setProduct(p1);
		d2.setProduct(p2);
		
		d1.setQuantity(1);
		d2.setQuantity(2);
		
		//add the details to a list of details
		List dl = new LinkedList();
		dl.add(d1);
		dl.add(d2);
		
		
		//create the order
		Order o = new Order();
		//we put as ID for the order the current time in milliseconds.
		o.setOrderID(""+System.currentTimeMillis());
		o.setDeliverto(a);
		o.setDetails(dl);
		o.setPayment(cc);
		o.setPlacedbyCustomer(new String("user 1"));
		o.setTimeplaced(new Date());
		
		//usage of IPOSProcessor interface as BO
		
		IPOSProcessor pos = new POSProcessor();
		pos.placeOrder(o);
		
		
		
		
		
		
		
		
		
	}

}
